﻿function DeleteEntry(source, itemID) {
    if (confirm("This entry will be deleted. Are you sure?")) {
        alert(itemID);
        __doPostBack(source, "DELETE:" + itemID);  
    }
}

/* http://msdn.microsoft.com/en-us/library/ff408909.aspx */
function OpenEntryReadyOnlyMode(source, itemID) {
    var options = SP.UI.$create_DialogOptions();
    options.url = "/_layouts/DevSkyDBConnectWP/DLGDetailView.aspx?MODE=READ&id=" + itemID;
    options.autoSize = true;
    options.dialogReturnValueCallback = Function.createDelegate(null, readyOnlyClosedCallback);
    var dialog = SP.UI.ModalDialog.showModalDialog(options);    
}

function OpenEntryEditMode(source, itemID) {
    var options = SP.UI.$create_DialogOptions();
    options.url = "/_layouts/DevSkyDBConnectWP/DLGDetailView.aspx?MODE=EDIT&id=" + itemID;
    options.autoSize = true;
    options.dialogReturnValueCallback = Function.createDelegate(null, readyOnlyClosedCallback);
    var dialog = SP.UI.ModalDialog.showModalDialog(options);
}

function CreateEntry(source, itemID) {
    var options = SP.UI.$create_DialogOptions();
    options.url = "/_layouts/DevSkyDBConnectWP/DLGDetailView.aspx?MODE=NEW&id=" + itemID;
    options.autoSize = true;
    options.dialogReturnValueCallback = Function.createDelegate(null, readyOnlyClosedCallback);
    var dialog = SP.UI.ModalDialog.showModalDialog(options);
}

function readyOnlyClosedCallback(result, value) {
    SP.UI.ModalDialog.RefreshPage(result);
  //this.statusId = SP.UI.Status.addStatus("Dialog closed","Just for fun ...",true);
  //SP.UI.Status.setStatusPriColor(this.statusId, "Green");
  //setTimeout(ClearNotification, 6000);
}

function ClearNotification() {
    SP.UI.Status.removeStatus(this.statusId);
}